package Thread;

public class Dom8 {
    public static void main(String[] args) throws InterruptedException {
        Thread t=new Thread(()->{
            while (true){
                System.out.println("hello Therad!");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"T1");
        //判断线程是否存活
        System.out.println(t.isAlive());
        //把t设置为后台进程
        t.setDaemon(true);
        System.out.println("创建线程");
        t.start();
        for (int i = 0; i <3 ; i++) {
            System.out.println("hello Therad!");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        System.out.println("main 进程结束判断thread线程是否存活");
        System.out.println(t.isAlive());
    }

}
